require('dotenv').config()
const cors = require('cors')
const sequelize = require('./db')
const models = require('./models/models')
const router = require('./routes/index')
const path = require('path')

const express = require('express')
const app = express()

app.use(cors())
app.use(express.json())
app.use('/api', router)

const PORT = process.env.PORT || 6666
const startServer = async () => {
  try {
    await sequelize.authenticate()
    await sequelize.sync()
    app.listen(PORT, () => console.log('[Server started]'))
  } catch (e) {
    console.log(e)
  }
}

const server = startServer() 
